#include "RBSphereToRBCubeCollision.h"

bool CheckCollision(const OOBB3& oobb, const RBSphere* rb)
{
	BoxPoints3 bp;
	CalculateOOBBCorners(oobb, bp);

	D3DXVECTOR3 rbPos = rb->GetPosition();

	float radius = rb->GetRadius() * rb->GetRadius();

	for (int i = 0; i != 8; i++)
	{
		D3DXVECTOR3 connectingVector = rbPos - bp.corners[i];

		float dist = D3DXVec3LengthSq(&connectingVector);

		if (radius > dist)
		{
			return true;
		}
	}

	// need to add sphere to plane collision

	return false;
}